home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Magazine / Online / HLHandler110 / extras / CleanUpHotList.rexx next >
OS/2 REXX Batch file  |  1996-12-07  |  1KB  |  71 lines

  1. /* $VER: CleanUpHotList.rexx 1.0 © Robert Nienkemper
  2.  *
  3.  * This script will clean-up an AWeb's hotlist created by the Arexx
  4.  * utility 'AddToHotlist.aweb' from Robert Nienkemper
  5.  *
  6.  */
  7.  
  8. Signal ON Syntax
  9.  
  10. Temp = "T:HLH.temp"
  11.  
  12. Parse Arg file
  13.  
  14.  /* open files */
  15.  
  16. If Exists(file) Then
  17.  Do
  18.   If ~Open('infile',file,R) Then Exit 20
  19.   If ~Open('outfile',Temp,W) Then
  20.    Do
  21.     Call Close('infile')
  22.     Exit 20
  23.    End
  24.  
  25.   /* read & write the first line */
  26.  
  27.  ol=ReadLN('infile')        
  28.  Call WriteLN('outfile',ol) 
  29.  
  30.  /* skip the index group created by AddToHotlist.aweb */
  31.  
  32.  ol=ReadLN('infile')
  33.  If((Index(ol,"<B>Index")>0) & ~Eof('infile')) Then
  34.    Do While ~Eof('infile')
  35.     ol=ReadLN('infile') 
  36.     If(Index(ol,"@ENDGROUP")) Then Leave
  37.    End
  38.   Else Call Seek('infile',-(Length(ol)+1))
  39.  
  40.  /* clean-up the rest of file */
  41.  
  42.  ng="@GROUP "
  43.  Do Forever
  44.   ol=ReadLN('infile')
  45.   If Eof('infile') Then Leave
  46.    If(Index(ol,"@GROUP") & (Index(ol,"<B>")>0)) Then
  47.        nl=ng||Substr(ol,Pos('>',ol)+1,Pos('</B>',ol)-(Pos('>',ol)+1))
  48.     Else If(Index(ol,"#index")) Then
  49.           Do
  50.            ol=ReadLN('infile')
  51.            nl=ReadLN('infile')
  52.           End
  53.      Else nl=ol
  54.     Call WriteLN('outfile',nl)
  55.  End
  56.  
  57. Call Close('infile')
  58. Call Close('outfile')
  59.  
  60. Address Command Copy '"'Temp'"' '"'file'"'
  61.  
  62. End
  63.  
  64.  
  65. If Exists(Temp) Then
  66.   Address Command Delete '"'Temp'"' ">NIL:"
  67.  
  68. Exit
  69.  
  70. /* EOF */
  71.